<template>
    <div class="tasks__task-subtasks">
        <TaskRow v-for="task in getSubtasks(task)" :task="task" :all-tasks="allTasks" :level="level"></TaskRow>
    </div>

</template>
<script>
    import _ from 'lodash'
    import TaskRow from './TaskRow.vue'

    export default {
        components: {
            TaskRow
        },

        name: 'subtasks',

        props: [
            'task',
            'allTasks',
            'level'
        ],

        data() {
            return {}
        },

        methods: {
            getSubtasks: function(task) {
                var tasks = _.filter(this.allTasks, function(o) {
                    if (o.parent_task == task.id) {
                        return o;
                    }
                });
                if(tasks.length > 0) {
                    return tasks;
                } else {
                    return false;
                }
            }
        },

        created: function() {

        }
    }
</script>